<?php

namespace app\admin\controller;

use app\common\controller\Backend;
use fast\Http;

use think\Config;

/**
 * 控制台
 *
 * @icon fa fa-dashboard
 * @remark 用于展示当前系统中的统计数据、统计报表及重要实时数据
 */
class Dashboard extends Backend
{
    public function _initialize()
    {
		parent::_initialize();
		$this->User = model('User');
		$this->LihuaOrder = model('LihuaOrder');
	}
    /**
     * 查看
     */
	public function index()
	{
		$admin = $this->view->admin;
        //今日新增用户
        // $UserNumber = $this->User->whereTime('jointime', 'd')->count();
		// $AmouthUserNumber = $this->User->whereTime('jointime', '-30 day')->count();
        // $AllUserNumber = $this->User->count();

        // //今日新增订单
		// $OrderNumber = $this->LihuaOrder
		// 	->whereTime('create_time', 'd')
		// 	->where(array('status'=>array('egt',2)))
		// 	->count();
		
        // //今日销售额
		// $todayAmount  = $this->LihuaOrder
		// 	->whereTime('create_time', 'd')
		// 	->where(array('status'=>array('egt',2)))
		// 	->sum('order_amount');

		// //七日内的数据统计
		// $sevenOrderAmount = $this->LihuaOrder::whereTime('create_time', '-6 day')
		// 	->where(array('status' => array('egt',2)))
		// 	->sum('order_amount');
		
		// //统计平台总销售额	
		// $AllOrderAmount = $this->LihuaOrder::where(array('status' => array('egt',2)))->sum('order_amount');

		$UserNumber = $AmouthUserNumber = $AllUserNumber = $OrderNumber = $todayAmount = $sevenOrderAmount = $AllOrderAmount = 0;

		
        //今日钱包充值
        $WalletMoney = 0;
		$this->view->assign('UserNumber', $UserNumber);
		$this->view->assign('AllUserNumber', $AllUserNumber);
        $this->view->assign('OrderNumber', $OrderNumber);
        $this->view->assign('todayAmount', $todayAmount);
		$this->view->assign('sevenOrderAmount', $sevenOrderAmount);
		$this->view->assign('AllOrderAmount', number_format($AllOrderAmount,0,'.',','));
		$this->view->assign('AmouthUserNumber', $AmouthUserNumber);
		$this->view->assign('cityid', $admin['city_id']);
		$this->view->assign('dayday', !!(date("Y/m/d")=="2020/01/21"));
        return $this->view->fetch();
    }
}
